<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>25.自定义过滤函数理解原理</title>
</head>
<body>
  <script>
    let hd = [1,2,3,4];
    function filter(array,callback) {
      let newArray = [];
      for(const value of array)
        if(callback(value)===true)
          newArray.push(value);
            
      return newArray;
    }
    console.log(filter(hd,function(value){
      return value >2;
    }));
  </script>
</body>
</html>